package utils;

import java.util.LinkedHashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.cloud.utils.AES128Util;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@Slf4j
class AES128UtilTest {

    final String aesKey = "";
    final String aesIV = "";

    @Test
    void encrypt() throws Exception {

//        final LoginTypeEnum aesKey = "4CvlKyKiaN6ZCcK2";
//        final LoginTypeEnum aesIV = "0szGdyGObQewV6D2";

        Map<String, String> valuesMap = new LinkedHashMap<>();
        valuesMap.put("签名私钥", "b53aa9d0605aa2281f3590a9a3c60331f6ed053a113734873ddb6f8d4069d90d7e47d8b6dc5d236d8caa66273ec19ce1");
        valuesMap.put("SCP_NODE_PRODUCT_ADDRESS", "f310932657e5dbc7d77a1bb9bf3cb7b06e60bec818c2f99e847ba4a53e3e578f656c3a3d25176d24063b2d8ee62136f9890aff4afd77daad751b7eca2639696c");
//        valuesMap.put("SCP_TOKEN_ADDRESS", "0x2103078FD63Ddbeed2553b8395dd9780e8BFAeF4");
//        valuesMap.put("STAKE_CONTRACT_ADDRESS", "8ad24237cd41965be0b033dcf6343bd8e3f56f4858da3f3337155bd8ec2ef476");
//        valuesMap.put("MINTER_CONTRACT_ADDRESS", "0x391180bBCb04d62019A1Ec132CfB7aa3924A2609");
//        valuesMap.put("LP_STAKE_CONTRACT_ADDRESS", "0xCb68CA4b1b14cfB1E4f495b3a59e0de0E27Cc1D5");
//        valuesMap.put("USDT_CONTRACT_ADDRESS", "0x55d398326f99059fF775485246999027B3197955");
//        valuesMap.put("PAIRED_CONTRACT_ADDRESS", "0x352e8bCAA0B5ff15cCA7EF578D7ccE0FC8eC3b32");
//        valuesMap.put("bsc-操作地址", "0xe9a6a1a0e3debda8ca232fa43d7e265538cbbdc7");
//        valuesMap.put("bsc-操作地址私钥", "0x8f9052c6707c509d1370ebac28591a1191fd4c97b5fc02365a9dd86d71a8fb35");
//        valuesMap.put("bsc-手续费地址", "0x280965708d1246cc6be931d93619a97a3408a42b");
//        valuesMap.put("bsc-手续费地址私钥", "0x8cea570e875acec33ef071b53df804799acf89ba2e41dfe825b80f3061d03c2d");
//        valuesMap.put("bsc-邮箱密码", "gHtyLrqHcHcpwNzV");

        for (String key : valuesMap.keySet()) {
            final String str = valuesMap.get(key);
            final String encStr = AES128Util.single().encrypt(str, aesKey, aesIV);
            log.info("[{}]加密后={}", key, encStr);
            final String decStr = AES128Util.single().decrypt(encStr, aesKey, aesIV);
            Assertions.assertEquals(str, decStr);
        }
    }

    @Test
    void decrypt() throws Exception {

        Map<String, String> valuesMap = new LinkedHashMap<>();
        valuesMap.put("旧地址", "050d53b89efa77c13e762b983dff85ecedc25833fb2c015b91d635acb5960efc7f25ae2f8d3b1a6dc2e4eca170a2e385");
        valuesMap.put("新地址", "fe1ba783e3b9ed990763624e49c4edeabbadcd23888225348a7ba74dbd5b0f06b7f682b2b8bb5d0ddc432b17bf9d0e78");
        valuesMap.put("旧地地址:privateKey",
            "a98980901e7d375b273bc274e1af4df040328e56f1ef930c0e768d5d61aa21ef372ea33f1215d96475b652fa79371186709dc865de0280a48e3f979cba1a98d21f0760dd8d422928510e54fc7064239a");
//        valuesMap.put("操作地址", "0xE9A6a1A0e3DeBDA8cA232fa43D7E265538CBbDC7");
//        valuesMap.put("操作地址私钥", "0x8f9052c6707c509d1370ebac28591a1191fd4c97b5fc02365a9dd86d71a8fb35");
//        valuesMap.put("手续费地址", "0x280965708D1246cc6BE931D93619A97A3408A42B");
//        valuesMap.put("手续费地址私钥", "0x8cea570e875acec33ef071b53df804799acf89ba2e41dfe825b80f3061d03c2d");
        for (String key : valuesMap.keySet()) {
            final String str = valuesMap.get(key);
            final String decStr = AES128Util.single().decrypt(str, aesKey, aesIV);
            log.info("[{}]解密后={}", key, decStr);
        }


    }
}